{% load static from staticfiles %}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>修改应用</title>
    <link rel="stylesheet" href="{% static "layui/css/layui.css" %}" media="all">
<style>


</style>
</head>

<body>

        <div class="layui-tab layui-tab-card" style="margin-top:0px;">
                <ul class="layui-tab-title">
                      <li class="layui-this"><i class="layui-icon">&#xe68e;</i><span></span>修改应用</li>
                </ul>
            </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>修改应用</legend>
    </fieldset>
    <form class="layui-form" action="/plugin/appConfig_update" method="post">
              <div class="layui-form-item">
                    <label class="layui-form-label">应用名称</label>
                    <div class="layui-input-block">
                      <input type="hidden" value="{{app.id}}" name="appid"/>
                      <input type="text" value="{{app.app_name}}" name="appname" lay-verify="required" autocomplete="off" placeholder="输入应用名称" class="layui-input">
                    </div>
              </div>   

            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="sub">修改</button>
              </div>
            </div>
          </form>               
    
                       
<script src="{% static "layui/layui.js"%}"></script>
<script>
    layui.use(['jquery','form','layer'], function() {
            var $ = layui.jquery,
            form=layui.form,
            layer=layui.layer;

            form.on('submit(sub)', function(data) {
                    var appid=data.field.appid;
                    var appname=data.field.appname;
                    var jsonval={"appname":appname,"appid":appid};
                    var url=data.form.action;
                    $.post(url,jsonval,function(result){
                        if(result.data=='0'){
                            layer.msg("应用名重复",{time:1000});
                        }else if(result.data=='-1'){
                            layer.msg("修改失败",{time:1000});
                        }else{
                            layer.msg("修改成功",{time:1000},function(){
                                window.location.href="/plugin/appConfig";
                            });
                        }
                    })
                    return false;
            });
    });

</script>       

</body>

</html>